package com.xyzwps.lib.ap;

import javax.annotation.processing.ProcessingEnvironment;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UncheckedIOException;

public class JavaFileWriter {

    public static void write(String classFullName, String sourceCode, ProcessingEnvironment processingEnv) {
        try {
            var sourceFile = processingEnv.getFiler().createSourceFile(classFullName);
            try (var out = new PrintWriter(sourceFile.openWriter())) {
                out.write(sourceCode);
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
}
